package com.uni.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uni.common.entity.UserAddr;
import com.uni.dto.UserAddrDTO;
import com.uni.mapper.UserAddrMapper;

/**
 * 收货地址
 * @author yuyanzheng
 *
 */
@Service
public class UserAddrService {

	@Autowired
	private UserAddrMapper userAddrMapper;
	
	@Transactional(rollbackFor=Exception.class)
	public int insert(UserAddr userAddr) {
		return userAddrMapper.insert(userAddr);
	}

	public int countByUserId(Long userId) {
		return userAddrMapper.countByUserId(userId);
	}

	public List<UserAddrDTO> findList(Long userId) {
		return userAddrMapper.findList(userId);
	}

	@Transactional(rollbackFor=Exception.class)
	public void del(UserAddr userAddr) {
		userAddrMapper.del(userAddr);
	}

	@Transactional(rollbackFor=Exception.class)
	public int update(UserAddr userAddr) {
		return userAddrMapper.update(userAddr);
	}

	@Transactional(rollbackFor=Exception.class)
	public void updateOhterStatus(Long id, Long userId) {
		userAddrMapper.updateOhterStatus(id,userId);
	}

	public UserAddrDTO findDefault(Long userId) {
		return userAddrMapper.findDefault(userId);
	}

	@Transactional(rollbackFor=Exception.class)
	public void delete(String[] ids, Long userId) {
		userAddrMapper.delete(ids,userId);
	}

}
